From 34b4c049d3074cfc88b9bd53ec198e84a9c1024f Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 9 Jan 2006 17:07:30 +0000 Subject: [PATCH] Always duplicate badchar string into handle to eliminate special cases on the handle release. --- mkshort.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mkshort.c b/mkshort.c index a035062dc..cba30f3e4 100644 --- a/mkshort.c +++ b/mkshort.c @@ -85,7 +85,7 @@ mkshort_new_handle() QUEUE_INIT(&h->namelist[i]); h->whitespaceok = 1; - h->badchars = DEFAULT_BADCHARS; + h->badchars = xstrdup(DEFAULT_BADCHARS); h->target_len = DEFAULT_TARGET_LEN; h->must_uniq = 1; h->defname = xstrdup("WPT"); @@ -278,13 +278,9 @@ setshort_badchars(short_handle h, const char *s) { mkshort_handle *hdl = (mkshort_handle *) h; - if ((hdl->badchars != NULL) && (hdl->badchars != DEFAULT_BADCHARS)) + if ((hdl->badchars != NULL)) xfree(hdl->badchars); - if (s == NULL) { - hdl->badchars = DEFAULT_BADCHARS; - } else { - hdl->badchars = xstrdup(s); - } + hdl->badchars = xstrdup (s ? s : DEFAULT_BADCHARS); } /* -- 2.30.2